package com.workflow.action;

import java.util.List;

import com.base.bean.Agentbase;
import com.base.bean.Personnelsales;
import com.base.service.AgentbaseService;
import com.base.service.DictService;
import com.base.service.PersonnelsalesService;
import com.common.bean.Datadict;
import com.common.bean.Personnel;
import com.common.util.PagerModel;
import com.common.util.StringToken;
import com.core.ssh2.AbstractActionSupport;
import com.opensymphony.xwork2.Preparable;
import com.workflow.bean.Listsales;
import com.workflow.service.ListsalesService;

public class ListsalesManagerAction extends AbstractActionSupport implements
		Preparable {
	private static final long serialVersionUID = 4592801986585108920L;

	private ListsalesService listsalesService;
	
	private AgentbaseService agentbaseService;
	
	private PersonnelsalesService personnelsalesService;
	
	private DictService dictService;
	
	private Listsales listsales;
	
	private long listid;
	
	private PagerModel pm;
	
	private List<Agentbase> agentbaselist;
	
	private List<Personnelsales> personnelsaleslist;
	
	private List<Datadict> datadictByPaylist;
	
	private List<Datadict> datadictBySalestypelist;
	
	private Datadict datadictByPay;

	private Datadict datadictBySalestype;

	@SuppressWarnings("unchecked")
	public void prepare() throws Exception {
		agentbaselist = agentbaseService.findAllAgentbase();
		personnelsaleslist = personnelsalesService.findAllPersonnelsales();
		datadictByPaylist = dictService.findDictDetail(StringToken.DICT_WORK_PAY);
		datadictBySalestypelist = dictService.findDictDetail(StringToken.DICT_WORK_SALESTYPE);
	}

	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}
	
	public String goAddListsales() throws Exception {
		return SUCCESS;
	}
	
	public String addListsales() throws Exception {
		Personnel personnel = (Personnel) getSession().get(StringToken.CURRENT_LOGIN);
		listsales.setPersonnel(personnel);
		
		listsalesService.addListsales(listsales);
		return SUCCESS;
	}
	
	public String findAllListsales() throws Exception {
		pm = listsalesService.findListsalesForPager();
		return SUCCESS;
	}
	
	public String findListsales() throws Exception {
		listsales = listsalesService.findListsales(listid);
		return SUCCESS;
	}
	
	public String delListsales() throws Exception {
		//需要删除相应的salescard信息
		listsalesService.removeListsales(listid);
		return SUCCESS;
	}
	
	public String getListsalesForUpdate() throws Exception {
		listsales = listsalesService.findListsales(listid);
		return SUCCESS;
	}
	
	public String updateListsales() throws Exception {
		listsalesService.updateListsales(listsales);
		return SUCCESS;
	}

	/**
	 * @return the agentbaselist
	 */
	public List<Agentbase> getAgentbaselist() {
		return agentbaselist;
	}

	/**
	 * @param agentbaselist the agentbaselist to set
	 */
	public void setAgentbaselist(List<Agentbase> agentbaselist) {
		this.agentbaselist = agentbaselist;
	}

	/**
	 * @return the agentbaseService
	 */
	public AgentbaseService getAgentbaseService() {
		return agentbaseService;
	}

	/**
	 * @param agentbaseService the agentbaseService to set
	 */
	public void setAgentbaseService(AgentbaseService agentbaseService) {
		this.agentbaseService = agentbaseService;
	}

	/**
	 * @return the datadictByPay
	 */
	public Datadict getDatadictByPay() {
		return datadictByPay;
	}

	/**
	 * @param datadictByPay the datadictByPay to set
	 */
	public void setDatadictByPay(Datadict datadictByPay) {
		this.datadictByPay = datadictByPay;
	}

	/**
	 * @return the datadictByPaylist
	 */
	public List<Datadict> getDatadictByPaylist() {
		return datadictByPaylist;
	}

	/**
	 * @param datadictByPaylist the datadictByPaylist to set
	 */
	public void setDatadictByPaylist(List<Datadict> datadictByPaylist) {
		this.datadictByPaylist = datadictByPaylist;
	}

	/**
	 * @return the datadictBySalestype
	 */
	public Datadict getDatadictBySalestype() {
		return datadictBySalestype;
	}

	/**
	 * @param datadictBySalestype the datadictBySalestype to set
	 */
	public void setDatadictBySalestype(Datadict datadictBySalestype) {
		this.datadictBySalestype = datadictBySalestype;
	}

	/**
	 * @return the datadictBySalestypelist
	 */
	public List<Datadict> getDatadictBySalestypelist() {
		return datadictBySalestypelist;
	}

	/**
	 * @param datadictBySalestypelist the datadictBySalestypelist to set
	 */
	public void setDatadictBySalestypelist(List<Datadict> datadictBySalestypelist) {
		this.datadictBySalestypelist = datadictBySalestypelist;
	}

	/**
	 * @return the dictService
	 */
	public DictService getDictService() {
		return dictService;
	}

	/**
	 * @param dictService the dictService to set
	 */
	public void setDictService(DictService dictService) {
		this.dictService = dictService;
	}

	/**
	 * @return the listid
	 */
	public long getListid() {
		return listid;
	}

	/**
	 * @param listid the listid to set
	 */
	public void setListid(long listid) {
		this.listid = listid;
	}

	/**
	 * @return the listsales
	 */
	public Listsales getListsales() {
		return listsales;
	}

	/**
	 * @param listsales the listsales to set
	 */
	public void setListsales(Listsales listsales) {
		this.listsales = listsales;
	}

	/**
	 * @return the listsalesService
	 */
	public ListsalesService getListsalesService() {
		return listsalesService;
	}

	/**
	 * @param listsalesService the listsalesService to set
	 */
	public void setListsalesService(ListsalesService listsalesService) {
		this.listsalesService = listsalesService;
	}

	/**
	 * @return the personnelsaleslist
	 */
	public List<Personnelsales> getPersonnelsaleslist() {
		return personnelsaleslist;
	}

	/**
	 * @param personnelsaleslist the personnelsaleslist to set
	 */
	public void setPersonnelsaleslist(List<Personnelsales> personnelsaleslist) {
		this.personnelsaleslist = personnelsaleslist;
	}

	/**
	 * @return the personnelsalesService
	 */
	public PersonnelsalesService getPersonnelsalesService() {
		return personnelsalesService;
	}

	/**
	 * @param personnelsalesService the personnelsalesService to set
	 */
	public void setPersonnelsalesService(PersonnelsalesService personnelsalesService) {
		this.personnelsalesService = personnelsalesService;
	}

	/**
	 * @return the pm
	 */
	public PagerModel getPm() {
		return pm;
	}

	/**
	 * @param pm the pm to set
	 */
	public void setPm(PagerModel pm) {
		this.pm = pm;
	}
	
	
}
